package com.py.credit.controller;

import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.entity.AuthorizeLog;
import com.py.credit.service.AuthorizeLogService;
import com.py.framework.core.common.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 授权测算日志
 *
 * @author YaoS
 * @date 2019-05-13 15:00
 */
@RestController
@RequestMapping("/authorizeLog")
public class AuthorizeLogController {

    @Autowired
    private AuthorizeLogService logService;

    /**
     * 分页查询日志对象信息
     *
     * @param dept    部门名称
     * @param model   模型名称
     * @param company 企业名称
     * @param page    分页信息
     * @return 查询结果
     * @author YaoS
     * @date 19/5/13 14:59
     */
    @RequestMapping(value = "/findLogListForPage.json")
    public RestServiceResult<List> selectModelListForPage(
            @RequestParam(value ="dept", defaultValue = "", required = false) String dept,
            @RequestParam(value ="model", defaultValue = "", required = false) String model,
            @RequestParam(value ="company", defaultValue = "", required = false) String company,
            Page page) {
        List<AuthorizeLog> list = logService.selectLogListForPage(dept, model, company, page);
        return new RestServiceResult<>(page.getTotalCount(), list);
    }

    /**
     * 功能描述:分页查询日志信息
     *
     * @param id id
     * @return 查询结果
     * @author YaoS
     * @date 19/5/13 14:59
     */
    @RequestMapping(value = "/findLogDetail.json")
    public RestServiceResult<AuthorizeLog> findLogDetail(String id) {
        AuthorizeLog log = logService.selectLogDetail(id);
        return new RestServiceResult<>(log);
    }

}
